﻿@model YCMS.Models.DockListViewModel


@{
    ViewBag.Title = "Dock List";
    PagedList.PagedList<YCMS.Domain.Entities.Dock> docks = (PagedList.PagedList<YCMS.Domain.Entities.Dock>)Model.docks;
}

<h2>Dock List</h2>
<p>
    @Html.ActionLink("Create New", "Create")
</p>

<table>
    <tr>
        <th></th>
        <th>@Html.ActionLink("Dock Name", "List", new {sortOrder = ViewBag.DockNameSortOrder})</th>
        <th>@Html.ActionLink("Dock Area", "List", new {sortOrder = ViewBag.DockAreaSortOrder})</th>
        <th>Max Length</th>
        <th>Max Beam</th>
        <th>@Html.ActionLink("Vacant", "List", new {sortOrder = ViewBag.VacantSortOrder})</th>
    </tr>
    @foreach (var d in Model.docks)
    {
    <tr>
    <td>
        @Html.ActionLink("Edit", "Edit", new { id = d.ID, sortOrder = Model.sortOrder, pageNumber = Model.pageNumber }) |
        @Html.ActionLink("Details", "Details", new {id = d.ID, sortOrder = Model.sortOrder, pageNumber = Model.pageNumber}) |
        @Html.ActionLink("Delete", "Delete", new {id = d.ID})
    </td>
    <td>
        @Html.DisplayFor(modelitem => d.DockName)
    </td>
    <td>
        @Html.DisplayFor(modelitem => d.DockArea)
    </td>
    <td>
        @Html.DisplayFor(modelitem => d.MaxLength)
    </td>
    <td>
        @Html.DisplayFor(modelitem => d.MaxBeam)
    </td>
    <td>
        @Html.DisplayFor(modelitem => d.Vacant)
    </td>
    </tr>
    }
</table>

<div> <!--Display Paging controls -->
    Page @(docks.PageCount < docks.PageNumber ? 0 : docks.PageNumber) of @docks.PageCount
    &nbsp
    @if (docks.HasPreviousPage)
    {
        @Html.ActionLink("<<", "List", new { page = 1, sortOrder = ViewBag.CurrentSort })
        @Html.Raw("&nbsp")
        @Html.ActionLink("< Prev", "List", new { page = docks.PageNumber - 1, sortOrder = ViewBag.CurrentSort })
    }
    else
    {
        @:<<
        @Html.Raw("&nbsp")
        @:< Prev
    }
    &nbsp
    @if (docks.HasNextPage)
    {
        @Html.ActionLink("Next >", "List", new { page = docks.PageNumber + 1, sortOrder = ViewBag.CurrentSort })
        @Html.Raw("&nbsp")
        @Html.ActionLink(">>", "List", new { page = docks.PageCount, sortOrder = ViewBag.CurrentSort })
    }
    else
    {
        @:Next >
        @Html.Raw("&nbsp")
        @:>>
    }
</div>